package com.sinosoft.dsp.security.utils;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import com.sinosoft.dsp.system.core.i18n.BaseMessages;

/**
 * 权限类型的枚举类
 * 
 * @author 潘巍（Peter Pan）
 * @since 2011-5-17 上午09:59:54
 */
public enum PrivilegeType {
	// 全部
	ALL("all"),
	// 本部门
	DEPARTMENT("dept"),
	// 本部门及子部门
	DEPARTMENT_AND_SUB("dept_and_sub"),
	// 子部门
	SUBDEPARTMENT("subdept");

	private static final String PKG = "com.sinosoft.dsp.security";

	public static final PrivilegeType DEFAULT_PRIVILEGE_TYPE = ALL;

	public static final String message_prefix = "privilege.type.";

	PrivilegeType(String key) {
		this.key = key;
		this.value = BaseMessages.getString(PKG, message_prefix + key);
	}

	private String key;

	private String value;

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public static final List<SelectItem> getSelectItems() {
		List<SelectItem> rtn = new ArrayList<SelectItem>();
		rtn.add(new SelectItem(ALL.key, ALL.value));
		rtn.add(new SelectItem(DEPARTMENT.key, DEPARTMENT.value));
		rtn
				.add(new SelectItem(DEPARTMENT_AND_SUB.key,
						DEPARTMENT_AND_SUB.value));
		rtn.add(new SelectItem(SUBDEPARTMENT.key, SUBDEPARTMENT.value));
		return rtn;
	}

}
